home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_toolbx.arc / PORTIO.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-03-30  |  1.5 KB  |  55 lines

  1. ;       portio.asm - 8088 port I/O functions
  2. ;
  3. ;       start data section
  4.         include begdata.ha
  5.         include enddata.ha
  6. ;
  7. ;       start code section
  8.         include begcode.ha
  9. ;
  10. ;       inport - read a byte from an 8088 port
  11. ;
  12. ;       USAGE: byte_value = inport(port_number) ;
  13. ;
  14. inport_args struc               ; input arguments
  15.         dw      0               ; saved BP value
  16.         dw      0               ; return address
  17. iport   dw      0               ; port number to read
  18. inport_args ends
  19. ;
  20.         public  inport
  21. inport:
  22.         push    bp
  23.         mov     bp,sp           ; set our arg pointer
  24.         mov     dx,word ptr iport[bp] ; set up port address
  25.         in      al,dx
  26.         xor     ah,ah
  27.         pop     bp
  28.         ret
  29. ;
  30. ;       output - write a byte to an 8088 port
  31. ;
  32. ;       USAGE:  outport(byte_value,port_number)  ;
  33. ;
  34. outport_args struc              ; input arguments
  35.         dw      0               ; saved BP value
  36.         dw      0               ; return address
  37. byte_value      dw     0        ; value to write
  38. oport   dw      0               ; write to this port number
  39. outport_args ends
  40. ;
  41.         public  outport
  42. outport:
  43.         push    bp
  44.         mov     bp,sp           ; set our arg pointer
  45.         mov     dx,word ptr oport[bp] ; get port address
  46.         mov     ax,word ptr byte_value[bp]
  47.         out     dx,al
  48.         pop     bp
  49.         ret
  50. ;
  51. ;
  52.         include endcode.ha
  53.         end
  54.  
  55.